<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>教师风采</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta name=”apple-mobile-web-app-status-bar-style” content=”default”/>
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black”/>
    <meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent”/>
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <meta name="format-detection" content="telephone=no"/>
    <link href="${s.base}/mobile/css/weui.min.css" rel="stylesheet"/>
    <link href="${s.base}/mobile/css/jquery-weui.min.css" rel="stylesheet">
    <link href="${s.base}/mobile/css/weChat.css" rel="stylesheet"/>
    <script type="text/javascript" src="${s.base}/mobile/js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="${s.base}/mobile/js/fontSize.js"></script>
    <script type="text/javascript" src="${s.base}/mobile/js/window_port.js"></script>
</head>
<body ontouchstart class="cyt-body-gray" style="width:100%;height:auto;overflow-y: auto;overflow-x: hidden!important;">
<!-- 搜索查询 -->
<div class="cyt-search-ctn">
    <div class="search-top">
        <i class="cytfonts">&#xe652;</i>请搜索你想要找的老师
    </div>
    <div class="search-input" style="display:none;">
        <i class="cytfonts">&#xe652;</i>
        <input type="text" placeholder="请输入关键字">
        <div class="search-cancel">取消</div>
    </div>
</div>
<!-- 教师风采列表 -->
<div class="cyt-teacherstyle-ctn">
    <ul>
    </ul>
</div>
<div class="weui-loadmore">
    <i class="weui-loading"></i>
    <span class="weui-loadmore__tips">正在加载</span>
</div>
<div class="nodate-ctn" style="display: none">
    <p>
        <img src="${s.base}/mobile/images/nodates.png"><br>
        <span>暂无数据</span>
    </p>
</div>
</body>
<script type="text/javascript" src="${s.base}/mobile/js/jquery-weui.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/fastclick.js"></script>
<script type="text/javascript" src="${s.base}/mobile/js/common.js"></script>
<script type="text/javascript">
    var page = 1;
    var limit = 10;
    var loading = false;
    $('.weui-loadmore').hide();
    $(".nodate-ctn").css("height", document.body.scrollHeight - 150);

    $(function () {
        FastClick.attach(document.body);
        initData();
        initListener();
    });

    function initData() {
        postData(1);
    }

    function initListener() {

        $(".search-top").bind("click", function () {
            $(".search-top").hide();
            $(".search-input").show();
            $(".search-input input").focus();
        });

        $(".search-cancel").bind("click", function () {
            $(".search-top").show();
            $(".search-input").hide();
            $(".search-input input").val("").blur();
            page = 1;
            limit = 10;
            postData(1);
        });

        $(".search-input input").on("input", function () {
            page = 1;
            limit = 10;
            postData(1);
        });

        $(document.body).infinite().on("infinite", function () {
            if (loading) return;
            loading = true;
            $('.weui-loadmore').show();
            setTimeout(function () {
                page++;
                postData(2);
            }, 1000);
        });
    }

    function postData(flag) {
        if (flag === 1) {
            $(document.body).infinite(100);
        }
        $.fn.doPost('/phone/teacher/page', {applyId: '${applyId}', name: $(".search-input input").val(), page: page, limit: limit}, function (result) {
            var str = '';
            if (result.code === 0) {
                for (var i = 0; i < result.data.length; i++) {
                    var e = result.data[i];
                    str += '<li>';
                    str += '<div class="teacher-photo"><img src="/sysFile/showFileByPath?path=' + e.path + '"></div>';
                    str += '<div class="view-teacher" id="' + e.id + '">查看</div>';
                    str += '<h1>' + e.name + '</h1>';
                    str += '<div class="teacher-post">职位：' + e.positionName + '</div>';
                    str += '<p class="ellipsis2">' + e.sexName + '，' + e.nationalName + '，';
                    str += e.dateBirth.substring(0, 4) + '年' + e.dateBirth.substring(5, 7) + '月生，' + e.birthPlace + '，' + e.description + '。';
                    str += '</li>';
                }
                if (!result.hasNextPage) {
                    $(document.body).destroyInfinite();
                }
            } else {
                $.toast('获取数据失败', "text");
            }
            if (flag === 1) {
                $('.cyt-teacherstyle-ctn ul').html(str);
            } else if (flag === 2) {
                loading = false;
                $(".weui-loadmore").hide();
                $('.cyt-teacherstyle-ctn ul').append(str);
            }
            $('.view-teacher').bind("click", function () {
                window.location.href = "/phone/teacher/teacherDetail?id=" + $(this).attr("id") + "&token=${token}&applyId=${applyId}";
            });
            var li = $('.cyt-teacherstyle-ctn ul li');
            if (li.length === 0) {
                $('.nodate-ctn').show();
            } else {
                $('.nodate-ctn').hide();
            }
        });
    }
</script>
</html>
